import { Tag, Space, Button, Popconfirm } from 'antd'
import { EditOutlined, DeleteOutlined } from '@ant-design/icons'


const btnClick = (data) => {
    console.log(data);
}

const confirm = (data, e) => {
    console.log(data, e);
}

export const HomeColumns = [
    {
        title: '封面',
        dataIndex: 'cover',
        width: 120,
        render: cover => {
            return <img src={cover.images[0]} width={80} height={60} alt="" />
        }
    },
    {
        title: '标题',
        dataIndex: 'title',
        width: 220
    },
    {
        title: '状态',
        dataIndex: 'status',
        render: data => <Tag color="green">审核通过</Tag>
    },
    {
        title: '发布时间',
        dataIndex: 'pubdate'
    },
    {
        title: '阅读数',
        dataIndex: 'read_count'
    },
    {
        title: '评论数',
        dataIndex: 'comment_count'
    },
    {
        title: '点赞数',
        dataIndex: 'like_count'
    },
    {
        title: '操作',
        render: data => {
            return (
                <Space size="middle">
                    <Button type="primary" shape="circle" icon={<EditOutlined />} onClick={() => btnClick(data)} />

                    <Popconfirm
                        title="确定删除?"
                        onConfirm={(e) => confirm(data.id, e)}
                        okText="确认"
                        cancelText="取消"
                    >
                        <Button
                            type="primary"
                            danger
                            shape="circle"
                            icon={<DeleteOutlined />}
                        />
                    </Popconfirm>
                </Space>
            )
        }
    }
]
